Ext.namespace('Ext.ux');

Ext.ux.TwinComboBox = function(config) {

	/* --------------------------- custom property ------------------------- */

	Ext.apply(this, config);

	/* --------------------------- override superclass property --------------------------- */

	Ext.ux.TwinComboBox.superclass.constructor.call(this, {
				triggerAction	: 'all',
				// editable : false,
				emptyText		: '请选择 ...',
				typeAhead		: true,
				selectOnFocus	: true,
				forceSelection	: true,
				mode			: 'local',
				hideTrigger1	: true,
				trigger1Class	: 'x-form-clear-trigger',
				onTrigger1Click	: this.clear.createDelegate(this)
			});

	/* --------------------------- event handler --------------------------- */

};

Ext.extend(Ext.ux.TwinComboBox, Ext.form.ComboBox, {
			initComponent	: Ext.form.TwinTriggerField.prototype.initComponent,
			getTrigger		: Ext.form.TwinTriggerField.prototype.getTrigger,
			initTrigger		: Ext.form.TwinTriggerField.prototype.initTrigger,
			onTrigger2Click	: Ext.form.ComboBox.prototype.onTriggerClick,
			trigger1Class	: Ext.form.ComboBox.prototype.triggerClass,
			onSelect		: function(record, index) {
				Ext.ux.TwinComboBox.superclass.onSelect.call(this, record,
						index
				);

				this.triggers[0].show();
			},
			clear			: function() {
				this.reset();
				this.triggers[0].hide();
			}
		}
);

Ext.reg('ux.twincombo', Ext.ux.TwinComboBox);